package fr.insalyon.sims.broadcast.network;

import java.io.IOException;

/**
 * Interface managing stream reception and emission.
 * 
 * @author GONZALEZ Silvia, GOTTERO Jeremie, SATTAYAKAWEE Nutchanat
 *
 */
public interface IStream {
	// ------------------------------------------------------- CONSTANTS -- //
	
	public final static int DEFAULT_BUFFER_SIZE = 8192;
	
	// --------------------------------------------------------- METHODS -- //
	
	/**
	 * Opens stream connection 
	 */
	public void connect() throws IOException;
	
	/**
	 * Activates the stream.
	 * 
	 */
	public void start();
	
	/**
	 * Deactivates the stream.
	 * 
	 */
	public void stop();

	/**
	 * Closes stream connection 
	 */
	public void disconnect() throws IOException;
	
	/**
	 * Adds error listener due to data
	 * 
	 * @param listener listener to be added
	 */
	public void addDataErrorListener(DataErrorListener listener);
	
	/**
	 * Removes error listener. This method does nothing when the listener isn't attached to the object.
	 * 
	 * @param listener listener to be removed
	 */
	public void removeDataErrorListener(DataErrorListener listener);
}
